﻿Imports Castle.ActiveRecord
Imports NHibernate
Imports NHibernate.Criterion

Namespace Model
    ''' <summary>
    ''' Criado em 07/01/2013 14:20:00
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable(), ActiveRecord("estoque_local", DynamicUpdate:=True)> _
    Public Class EstoqueLocal
        Inherits ActiveRecordBase(Of Model.EstoqueLocal)

        Private _cd_estoque_local As Integer
        Private _estoque_local_descricao As String

        Private _Estoques As IList(Of Model.Estoque)

        <PrimaryKey(PrimaryKeyType.Sequence, SequenceName:="estoque_local_cd_estoque_local_seq")> _
        Public Property cd_estoque_local As Integer
            Get
                Return _cd_estoque_local
            End Get
            Set(ByVal value As Integer)
                _cd_estoque_local = value
            End Set
        End Property

        <HasMany(GetType(Model.Estoque), Table:="estoque", Lazy:=True, Columnkey:="cd_estoque_local")> _
        Public Property Estoques() As IList(Of Model.Estoque)
            Get
                Return _Estoques
            End Get
            Set(ByVal value As IList(Of Model.Estoque))
                _Estoques = value
            End Set
        End Property

        <[Property]("estoque_local_descricao")> _
        Public Property estoque_local_descricao As String
            Get
                Return _estoque_local_descricao
            End Get
            Set(ByVal value As String)
                _estoque_local_descricao = value
            End Set
        End Property

        ''' <summary>
        ''' Pesquisa pela descrição
        ''' </summary>
        ''' <param name="Descricao">Texto a ser pesquisado</param>
        ''' <returns>Lista de EstoqueLocal</returns>
        ''' <remarks></remarks>
        Public Function GetByDescricao(ByVal Descricao As String) As IList(Of Model.EstoqueLocal)
            Dim Query As DetachedCriteria = DetachedCriteria.For(Of Model.EstoqueLocal)("estoque_local")

            Query.Add( _
                Restrictions.Like("estoque_local_descricao", Descricao, MatchMode.Anywhere).IgnoreCase())

            Return Model.EstoqueLocal.FindAll(Query)

        End Function

    End Class
End Namespace

